package com.liveinstars.im.common.dto;

import com.liveinstars.im.common.enums.GroupBigClassEnum;
import com.liveinstars.api.im.vo.ChatGroupDetailVO;
import com.liveinstars.api.im.vo.ChatGroupRecordVO;
import com.liveinstars.im.domain.dao.model.ChatGroup;
import com.liveinstars.im.domain.dao.model.ChatGroupMember;
import lombok.Data;
import lombok.ToString;

import java.util.List;

/**
 * @author: zhouze
 * @date: 2020/3/4
 */
@Data
@ToString
public class ChatGroupDTO {

    /**
     * 聊天群组
     */
    private ChatGroup chatGroup;

    /**
     * 成员列表
     */
    private List<ChatGroupMember> memberList;


    public ChatGroupDTO(ChatGroup chatGroup) {
        this.chatGroup = chatGroup;
    }

    public ChatGroupDTO(ChatGroupDetailVO vo) {
        this.chatGroup = new ChatGroup();
        chatGroup.setId(vo.getId());
        chatGroup.setName(vo.getChatGroupName());
        chatGroup.setGroupLogo(vo.getLogo());
        chatGroup.setBigClassId(vo.getBigClassId());
        chatGroup.setUserLevel(vo.getUserLevel());
        chatGroup.setIdentification(vo.getIdentification());
        chatGroup.setAuthRule(vo.getAuthRule());
        chatGroup.setHot(vo.getHot());
        chatGroup.setDescription(vo.getDescription());
    }

    /**
     * 实体转坏方法
     */
    public ChatGroupRecordVO chatGroupTransToChatGroupRecordVO() {
        ChatGroupRecordVO target = new ChatGroupRecordVO();
        target.setBigClassId(chatGroup.getBigClassId());
        target.setBigClassName(GroupBigClassEnum.valueOf(chatGroup.getBigClassId()).getText());
        target.setChatGroupName(chatGroup.getName());
        target.setCreateTime(Long.valueOf(chatGroup.getCreateDate()));
        target.setId(chatGroup.getId());
        target.setGroupLevel(chatGroup.getGroupLevel());
        target.setIdentification(chatGroup.getIdentification());
        target.setCreateUserId(chatGroup.getCreateById());
        target.setUserLevel(chatGroup.getUserLevel());
        target.setAuthRule(chatGroup.getAuthRule());
        target.setHot(chatGroup.getHot());
        target.setGroupLogo(chatGroup.getGroupLogo());
        target.setDescription(chatGroup.getDescription());
        return target;
    }

    public ChatGroupDetailVO chatGroupTransToChatGroupDetailVO() {
        ChatGroupDetailVO target = new ChatGroupDetailVO();
        target.setId(chatGroup.getId());
        target.setChatGroupName(chatGroup.getName());
        target.setLogo(chatGroup.getGroupLogo());
        target.setBigClassId(chatGroup.getBigClassId());
        target.setUserLevel(chatGroup.getUserLevel());
        target.setIdentification(chatGroup.getIdentification());
        target.setAuthRule(chatGroup.getAuthRule());
        target.setHot(chatGroup.getHot());
        return target;
    }
}
